package harima.agameditor.mapeditor.ui;

import harima.agameditor.common.control.AwesomeEditorEnviroment;
import harima.agameditor.common.ui.BaseEditorView;
import harima.agameditor.mapeditor.control.MapEditorController;
import harima.agameditor.resources.ActionCommands;
import harima.agameditor.resources.Labels;
import harima.agameditor.resources.PanelIds;

import java.awt.BorderLayout;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

public class MapEditorView_panel extends BaseEditorView<MapEditorController> {
	
	
	
	protected DisplayOptions_panel displayOptionsPanel;
	protected MapTools_panel mapToolsPanel;
	protected TileBrowser_panel tileBrowserPanel;
	protected MapBrowser_panel mapBrowserPanel;
	protected TilePalete_panel tilePaletePanel;
	protected MapCanvas_panel mapCanvasPanel;
	protected JButton saveMapButton;
	
	public MapEditorView_panel()
	{
		
		setLayout(new BorderLayout());
		JPanel northPanel = buildNorthPanel();
		JTabbedPane westPanel = buildWestPanel();
		mapToolsPanel = new MapTools_panel();		
		mapCanvasPanel = new MapCanvas_panel();
		
		add(northPanel, BorderLayout.NORTH);			
		add(westPanel, BorderLayout.WEST);
		add(mapToolsPanel, BorderLayout.SOUTH);
		add(mapCanvasPanel, BorderLayout.CENTER);
		
		registerPanels();
		
	}

	private JTabbedPane buildWestPanel() {
		tileBrowserPanel = new TileBrowser_panel();
		mapBrowserPanel = new MapBrowser_panel();
		tilePaletePanel = new TilePalete_panel();
		JTabbedPane tabbedPanel = new JTabbedPane();
		tabbedPanel.addTab(Labels.TileBrowserTitle, tileBrowserPanel);
		tabbedPanel.addTab(Labels.MapBrowserTitle, mapBrowserPanel);
		tabbedPanel.addTab(Labels.TilePaleteTitle, tilePaletePanel);
		
		return tabbedPanel;
	}

	private JPanel buildNorthPanel() {
		displayOptionsPanel = new DisplayOptions_panel();		
		saveMapButton = new JButton(ActionCommands.SaveMap);
		saveMapButton.setActionCommand(ActionCommands.SaveMap);
		JPanel northPanel = new JPanel(new BorderLayout());
		northPanel.add(saveMapButton, BorderLayout.WEST);
		northPanel.add(displayOptionsPanel, BorderLayout.CENTER);
		return northPanel;
	}
	
	private void registerPanels()
	{
		registerPanel(mapBrowserPanel);
		registerPanel(mapCanvasPanel);
		registerPanel(mapToolsPanel);
		registerPanel(displayOptionsPanel);
		registerPanel(tileBrowserPanel);
		registerPanel(tilePaletePanel);
	}
}
